package com.wingsboat;

import java.util.Scanner;

/**
 * @author wangzhong
 * @description: TODO
 * @date 2024/7/20 9:07
 */
public class Test4 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        UnionFind unionFind = new UnionFind(n+1);
        while(m>0){
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            int flag = scanner.nextInt();
            if(flag==0){
                unionFind.union(a,b);
            }else if(flag==1){
                if(unionFind.isUnion(a,b)){
                    System.out.println("we are a team");
                }else{
                    System.out.println("we are not a team");
                }
            }else{
                System.out.println("da pian zi");
            }
            m-=1;
        }
    }
}

class UnionFind{
    private int[] parent;
    public UnionFind(int length){
        parent = new int[length];
        for(int i=0;i<length;i++){
            parent[i] = i;
        };
    }

    public int find(int x){
        while(x!=parent[x]){
            x = parent[x];
        }
        return x;
    }

    public void union(int a,int b){
        parent[b] =a;
    }

    public boolean isUnion(int a,int b){
        return find(a)==find(b);
    }
}
